{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1002
  Verdict: Accepted
}
var n,i:integer; min:int64; a:array[-1..5001,1..3] of integer; res:array[-1..5001] of int64;
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
readln(n);
fillchar(res,sizeof(res),0);
for i:=-1 to 0 do begin
    a[i][1]:=30001;
    a[i][2]:=30001;
    a[i][3]:=30001;
end;
for i:=1 to n do readln(a[i][1],a[i][2],a[i][3]);
for i:=-1 to 0 do res[i]:=0;
res[1]:=a[1][1];
for i:=2 to n do begin
    min:=res[i-1]+a[i][1];
    if res[i-2]+a[i-1][2]<min then min:=res[i-2]+a[i-1][2];
    if res[i-3]+a[i-2][3]<min then min:=res[i-3]+a[i-2][3];
    res[i]:=min;
end;
writeln(res[n]);
end.